#include "declarations.h"

using namespace std;
void RemoveWhiteSpace (char* a)
{
	for (int i=0;i<=strlen(a);)
	{
		if (a[i]==' ') 
			for (int j=i;j<strlen(a);j++)
				a[j]=a[j+1];
		else i++;
	}
}
void FileRework (char* filename)
{
    ifstream input;
	ifstream input1;
	input.open(filename);
	input1.open(filename);
	ofstream output;
	output.open("operate.txt",ofstream::app);
	if (!input)
	{
		std::cout<<"error file "<<filename<<" can't be opened";
		return;
	}
	char a[100];
	int counter=0;
	while (input.good())
	{
		input.getline(a,99);
		counter++;
	}
    for (int i=0;i<counter;i++)
	{
		input1.getline(a,99);
		RemoveWhiteSpace(a);
		output<<a<<'\n';
	}
	input1.getline(a,99);
	input.close();
	input1.close();
	remove(filename);
	output.close();
	rename("operate.txt",filename);
	return;
}

int main()
{
	FileRework("cities.txt");
	FileRework("schedule.txt");
	
	train train;
	train.List();
    int n;
	cout<<"train u want to del";
	cin>>n;
	cin.get();
	train.Edit(n);
	system("PAUSE");
	return 0;
	
	
}





